package com.atguigu.tingshu.user.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.atguigu.tingshu.user.service.MqOpsService;
import com.atguigu.tingshu.user.startegy.ProcessDiffPayRecord;
import com.atguigu.tingshu.vo.user.UserPaidRecordVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @Author：yyj
 * @Package：com.atguigu.tingshu.user.service.impl
 * @Project：tingshu_parent240829
 * @name：MqOpsServiceImpl
 * @Date：2025/2/13 16:12
 * @Filename：MqOpsServiceImpl
 */
@Component
public class MqOpsServiceImpl implements MqOpsService {
    @Autowired
    private Map<String, ProcessDiffPayRecord> map;
    @Override
    public void updatePayRecord(String content) {
        //策略模式不需要适配 直接能找到对应的人干活（对应关系提前维护好了）
        // 适配器模式：需要适配  只有适配到自己 才能干自己的活（对应关系没有提前维护好了 一次一次去找）
        UserPaidRecordVo userPaidRecordVo = JSONObject.parseObject(content, UserPaidRecordVo.class);
        ProcessDiffPayRecord processDiffPayRecord = map.get(userPaidRecordVo.getItemType());
        processDiffPayRecord.processPayRecord(userPaidRecordVo);
    }
}